﻿using System;
using UnityEngine;

// Token: 0x020002D5 RID: 725
public class Voice : MonoBehaviour
{
	// Token: 0x060010E5 RID: 4325 RVA: 0x0007C050 File Offset: 0x0007A250
	private void Start()
	{
		this.anim = base.gameObject.GetComponent<Animator>();
		Transform boneTransform = this.anim.GetBoneTransform(HumanBodyBones.Chest);
		if (boneTransform)
		{
			if (!Voice.heartbeat)
			{
				Voice.heartbeat = Resources.Load<AudioClip>("Sound/Giantess/heartbeat");
			}
			this.chestSource = this.CreateAudioSource(boneTransform);
			this.chestSource.clip = Voice.heartbeat;
			this.chestSource.outputAudioMixerGroup = SoundManager.mg_macro;
			this.chestSource.Play();
		}
		Transform boneTransform2 = this.anim.GetBoneTransform(HumanBodyBones.Head);
		if (boneTransform2)
		{
			if (!Voice.breathing)
			{
				Voice.breathing = Resources.Load<AudioClip>("Sound/Giantess/female_breathing");
			}
			this.mouthSource = this.CreateAudioSource(boneTransform2);
			this.mouthSource.clip = Voice.breathing;
			this.mouthSource.outputAudioMixerGroup = SoundManager.mg_macro;
			this.mouthSource.Play();
			this.mouthSource.volume = 1f;
		}
	}

	// Token: 0x060010E6 RID: 4326 RVA: 0x0007C15C File Offset: 0x0007A35C
	private void Update()
	{
		this.scale = base.transform.localScale.y;
		if (this.chestSource)
		{
			this.chestSource.maxDistance = this.chestDistance * this.scale;
			this.chestSource.minDistance = this.chestSource.maxDistance * this.minDistancePercentage;
			this.chestSource.pitch = this.pitch;
		}
		if (this.mouthSource)
		{
			this.mouthSource.maxDistance = this.mouthDistance * this.scale;
			this.mouthSource.minDistance = this.mouthSource.maxDistance * this.minDistancePercentage;
			this.mouthSource.pitch = this.pitch;
		}
	}

	// Token: 0x060010E7 RID: 4327 RVA: 0x0007C230 File Offset: 0x0007A430
	private AudioSource CreateAudioSource(Transform bone)
	{
		AudioSource audioSource = bone.gameObject.AddComponent<AudioSource>();
		audioSource.outputAudioMixerGroup = SoundManager.mg_voice;
		audioSource.dopplerLevel = 0f;
		audioSource.spatialBlend = 1f;
		audioSource.volume = 1f;
		audioSource.loop = true;
		return audioSource;
	}

	// Token: 0x040015D7 RID: 5591
	private Animator anim;

	// Token: 0x040015D8 RID: 5592
	public AudioSource mouthSource;

	// Token: 0x040015D9 RID: 5593
	private AudioSource chestSource;

	// Token: 0x040015DA RID: 5594
	private static AudioClip heartbeat;

	// Token: 0x040015DB RID: 5595
	private static AudioClip breathing;

	// Token: 0x040015DC RID: 5596
	public float minDistancePercentage = 0.01f;

	// Token: 0x040015DD RID: 5597
	public float chestDistance = 100f;

	// Token: 0x040015DE RID: 5598
	public float mouthDistance = 120f;

	// Token: 0x040015DF RID: 5599
	public float pitch = 1f;

	// Token: 0x040015E0 RID: 5600
	private float scale;
}
